<?php

class PrimitiveJsonizer {
    function toPhpBoolean($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        return (boolean) $arg0;
    }
    
    function toPhpChar($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        $str = (string) $arg0;
        if (mb_strlen($str, 'UTF-8') != 1) {
            throw_exception("expecting 1 character long string [$arg0]");
        }
        
        return $str;
    }
    
    function toPhpShort($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string)$arg0;
    }
    
    function toPhpInteger($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string)$arg0;
    }
    
    function toPhpLong($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string)$arg0;
    }
    
    function toPhpFloat($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
    
    function toPhpDouble($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
    
    function toJsonBoolean($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        return (boolean) $arg0;
    }
    
    function toJsonChar($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        $str = (string) $arg0;
        if (mb_strlen($str, 'UTF-8') != 1) {
            throw_exception("expecting 1 character long string [$arg0]");
        }
        
        return $str;
    }
    
    function toJsonShort($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
    
    function toJsonInteger($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
    
    function toJsonLong($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
    
    function toJsonFloat($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        return (string) $arg0;
    }
    
    function toJsonDouble($arg0) {
        if ($arg0 === null) {
            throw_exception("expecting non-null value");
        }
        
        if (!is_numeric($arg0)) {
            throw_exception("expecting numeric value [$arg0]");
        }
        
        return (string) $arg0;
    }
}

?>
